import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Jiang Jinxi
 * Date: 2024-03-16
 * Time: 14:44
 */

public class Test3 {
    public static String[] sort(Double[] arr,String[] name){
        for (int i = 0; i < arr.length-1; i++) {
            for (int j = 0; j < arr.length-1-i; j++) {
                if (arr[j] < arr[j + 1]){
                    double tmp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = tmp;
                    String str = name[j];
                    name[j] = name[j + 1];
                    name[j + 1] = str;
                }
            }
        }
        return name;

    }
    public static void main(String[] args) {
        System.out.print("输入学生个数:");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        String[] name = new String[num];
        Double[] grade = new Double[num];
        for (int i = 1; i <= num; i++) {
            System.out.print("第" + i + "个同学姓名:");
            name[i - 1] = scanner.next();
            System.out.print("第" + i + "个同学成绩:");
            grade[i - 1] = scanner.nextDouble();
        }
        String[] name2 = sort(grade,name);
        System.out.println("成绩前两名同学:" + name2[0] + " " + name2[1]);


    }
}
